package com.example.quart.task;

import com.example.quart.controller.IndexController;
import lombok.extern.slf4j.Slf4j;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author LiYuhang
 * @version 0.1
 * @application
 * @Date 2020/11/1 15:31
 */
@Component
@DisallowConcurrentExecution
@Slf4j
public class UploadTask extends QuartzJobBean {
    @Autowired
    private IndexController indexController;

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        log.info(" 任务开始--current time -- :{} --- ",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
            log.error("executeInternal error {}",e.getMessage(),e);
        }
        log.info(" 任务结束--current time -- :{} --- ",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
    }
}
